﻿' 
' Copyright (C) 2014 Infinity CCS Ltd (http://www.infinityccs.com/)
' Copyright (C) 2008 Sasa Coh <sasacoh@gmail.com>
'
' This program is free software; you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation; either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program.  If not, see <http://www.gnu.org/licenses/>. 
'/

Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Media
Imports Infinity.pjsipNET.Common.Media

Namespace Common.Media
  Public Class DefaultMediaPlayer
    Implements IMediaProxy

    Private Shared _Instance As DefaultMediaPlayer = Nothing
    Public Shared ReadOnly Property Instance As DefaultMediaPlayer
      Get
        If _Instance Is Nothing Then _Instance = New DefaultMediaPlayer
        Return _Instance
      End Get
    End Property

    Private Sub New()

    End Sub

    Dim player As New SoundPlayer()

#Region "Methods"

    Public Function playTone(toneId As ETones) As Integer Implements IMediaProxy.playTone
      Select Case toneId
        Case ETones.EToneDial
          player.Stream = My.Resources.dial1
        Case ETones.EToneCongestion
          player.Stream = My.Resources.congestion
        Case ETones.EToneRingback
          player.Stream = My.Resources.ringback
        Case ETones.EToneRing
          player.Stream = My.Resources.ring
        Case Else
          player.Stream = Nothing
      End Select

      If player.Stream IsNot Nothing Then
        player.Load()
        player.PlayLooping()
      End If
      Return 1
    End Function

    Public Function stopTone() As Integer Implements IMediaProxy.stopTone
      player.Stop()
      Return 1
    End Function

#End Region


  End Class
End Namespace